import { request } from '@/plugins/request';
import type { communityTypes } from '@/types/dynamic';
import type { paginationTypes } from '@/types/global'

// 查询小区列表
export function getCommunityList(data:paginationTypes):Promise<communityTypes> {
    return request({
        url: '/community/communities/',
        method: 'GET',
        data
    })
}

export interface addCommunityParamsType {
    avatar: string,
    community_name: string,
    address: string,
    location: String,
    pname: string,
    cityname: string,
    adname: string,
    self_introduction: string,
    publication_count: number,
    community_population: number,
    followers_count: number,
    create_user_id: string,
    property_management_info: {
        property_management_company: string,
        phone_number: string,
        address: string,
        property_fees: string,
        households_count: string,
        electricity: {
            type: string,
            rate: string
        },
        water: {
            rate: string,
            type: string
        }
    },
    convenient_contact_information: any
    /* [
        {
            organization: string,
            phoneNumber: string,
            address: string
        }
    ] */
}

// 添加小区
export function addCommunityFun(data: addCommunityParamsType) {
    return request({
        method: "POST",
        url: '/community/communities/',
        data
    })
}

// //获取小区列表

// export function getCommunityList() {
//     return request({
//         method: "GET",
//         url: '/community/communities/?page=1&per_page=10',
//     })
// }

